/**
 * Class Button
 * This class manipulate the html used for button
 * Example:
 * //html for button
 * //<div class="button-holder">
 * //   <div class="button">
 * //       <span></span>
 * //   </div>
 * //</div>
 * var button = new Button("button-id");
 * button.setText("Button");
 * button.setType("back");
 * button.setAction(function(e){
 *      //this -> button instance
 *      //e -> event
 * });
 */
Button = (function(_super) {

    __extends(Button, _super);
	/**
	 * Button constructor
	 * @param view {View|String|HTMLElement} id, htmlelement or View
	 * @constructor
	 */
    function Button(view) {
        Button.__super__.constructor.call(this);
        this.setContentView(view);
        this._text = this.view.select("span");
        this.button = this.view.select(".button");
    }
	/**
	 * Overwrite set content view and create if we have no view
	 * @param view {View|String|HTMLElement}
	 */
	Button.prototype.setContentView = function(view){
		Button.__super__.setContentView.call(this, view || this.create());
	};
	/**
	 * Create view and html structure for this button class
	 * @returns {View}
	 */
	Button.prototype.create = function(){
		var view = new View(document.createElement("div"));
		view.addClass("button-holder activatable");
		view.html('<div class="button"><span></span></div>');
		return view;
	};
	/**
	 * Set Button text if button have this._text object
	 * @param text {String} Button text
	 */
    Button.prototype.setText = function(text) {
        if (!text) return;
        this._text.html(this.text = text);
    };
	/**
	 * Set Button type add css class to this.button object
	 * @param type {String}
	 */
    Button.prototype.setType = function(type) {
        if (!type)  return;
        this.button.addClass(this.type = type);
    };

    return Button;

})(Base);
